(function (window, undefined) {
    class Food {
        constructor({ width = 20, height = 20, left = 0, top = 0, backgroundColor = "skyblue" }) {
            this.width = width
            this.height = height

            this.left = left
            this.top = top

            this.color = backgroundColor

            this.bodys = []
        }
        render(parent, { left, top }) {
            const fo = document.createElement("div")
            fo.style.position = "absolute"
            fo.style.width = this.width + "px"
            fo.style.height = this.height + "px"

            fo.style.left = left + "px"
            fo.style.top = top + "px"

            fo.style.backgroundColor = this.color
            this.bodys.push(fo)

            parent.appendChild(fo)
        }
        position() {
            const left = Tools.getRandom(0, tage.offsetWidth / this.width - 1) * this.width
            const top = Tools.getRandom(0, tage.offsetHeight / this.width - 1) * this.width

            return { left, top }
        }
        removeFood(parent, i) {
            parent.removeChild(this.bodys[i])
            this.bodys.splice(i, 1)
        }
    }
    window.Food = Food
})(window, undefined);